//
//  RBServiceOrderVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/8/15.
//

#import "RBServiceOrderVC.h"
#import "RBDefine.h"
#import "UIView+RBAdd.h"
#import "UIScrollView+RBAdd.h"
#import <Masonry.h>
#import "RBThemeConfig.h"
#import <UIColor+YYAdd.h>
#import <UIView+YYAdd.h>
#import "RBPager.h"
#import <UINavigationController+FDFullscreenPopGesture.h>
#import "RanTool.h"
#import "RBServiceOrderCell.h"
#import "RBServiceOrderDetailVC.h"

@interface RBServiceOrderVC ()<UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>

@property(nonatomic, strong)UICollectionView *collectionView;
@property(nonatomic, strong)NSMutableArray *dataSource;

@end

@implementation RBServiceOrderVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
    [self fillData];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"售后/退款订单";
    self.view.backgroundColor = [RBThemeConfig bgGrayColor];
}

- (void)fillData
{
    __weak typeof(self) weakSelf = self;
    [self.dataSource addObject:({
        RBGroupModel *group = RBGroupModel.new;
        group.sectionInset = UIEdgeInsetsMake(Zoom(10), 0, Zoom(10), 0);
        group.minimumLineSpacing = Zoom(10);
        group.cellModels = ({
            NSMutableArray *arrayM = NSMutableArray.array;
            for (NSInteger i = 0; i < 20; i++)
            {
                [arrayM addObject:({
                    RBCellModel *cellModel = RBCellModel.new;
                    cellModel.reuseCellIdentifier = NSStringFromClass(RBServiceOrderCell.class);
                    cellModel.cellSelectBlock = ^(NSIndexPath *indexPath) {
                    };
                    cellModel.eventBlock = ^(id data) {
                        RBServiceOrderDetailVC *vc = RBServiceOrderDetailVC.new;
                        [weakSelf.navigationController pushViewController:vc animated:YES];
                    };
                    cellModel;
                })];
            }
            arrayM;
        });
        group;
    })];
    [self.collectionView reloadData];
}

#pragma mark - Network

#pragma mark - Event

#pragma mark - UICollectionViewDataSource & UICollectionViewDelegate

kRBCollectionViewDataSourceAndDelegateAuto(self.dataSource);

#pragma mark - Setter

#pragma mark - Getter

- (UICollectionView *)collectionView
{
    if (!_collectionView)
    {
        self.collectionView = ({
            UICollectionViewFlowLayout *layout = UICollectionViewFlowLayout.new;
            layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize;
            UICollectionView *view =  [UICollectionView.alloc initWithFrame:CGRectZero collectionViewLayout:layout];
            view.showsVerticalScrollIndicator = NO;
            view.showsHorizontalScrollIndicator = NO;
            view.dataSource = self;
            view.delegate = self;
            view.backgroundColor = UIColor.clearColor;
            kRBIgnoreScrollViewInsetsAdjust(view);
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(0);
                make.right.mas_equalTo(0);
                make.bottom.mas_equalTo(0);
                make.top.mas_equalTo(0);
            }];
            view;
        });
    }
    return _collectionView;
}
- (NSMutableArray *)dataSource
{
    if (!_dataSource)
    {
        self.dataSource = ({
            NSMutableArray *arrayM = NSMutableArray.array;
            arrayM;
        });
    }
    return _dataSource;
}


@end
